package com.asset.crm.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@SuppressWarnings("serial")
@Entity
@Table(name="post")
public class Post implements Serializable{

	private Integer id;
	
	private Employee poster;
	
	private String postText;
	
	private Date postDate;
	
	private List<Comment> comments;
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="post_id_seq")
	@SequenceGenerator(name="post_id_seq",sequenceName="post_id_seq",allocationSize=1)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@ManyToOne
	@JoinColumn(name="poster_id")
	public Employee getPoster() {
		return poster;
	}

	public void setPoster(Employee poster) {
		this.poster = poster;
	}
	@Column(name="post_text")
	public String getPostText() {
		return postText;
	}

	public void setPostText(String postText) {
		this.postText = postText;
	}
	@Column(name="post_date")
	public Date getPostDate() {
		return postDate;
	}

	public void setPostDate(Date postDate) {
		this.postDate = postDate;
	}
	@OneToMany(mappedBy="post" , fetch=FetchType.EAGER)
	public List<Comment> getComments() {
		return comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}
	
	
	
}
